﻿@{
    ViewBag.Title = "index";
    Layout = "~/Views/Shared/_Layout_User.cshtml";
    var CurrentUser = ViewBag.LoginUser as BabyPlan.mvcApp.ViewModel.UserModel;
    ResourceHelper.RegisterCss(this, "user.index.css");
}
@model IEnumerable<BabyPlan.mvcApp.ViewModel.ProductModel>
@section Js_InHeader{}
<div class="user_right_block bg_release ">
  <a class="button-green add_link button_pointer" href="@Url.Action("AddGoods", "User")">发布宝贝</a>
</div>
<div class="user_right_block whiteblock" style="margin:15px 0;">
    <span class="blue-font font-size16 bold line-height40" style="margin:10px;">同城最新动态</span>
    <div class="latest_list_outer user_right_block">
        <ul class="latest_list_box">
        @foreach (var item in Model)
        {
            if (item.Pics.Count >0)
            {
                item.Pics[0].DisplaySeting(120, 120);
            <li>
                <div class="itembox">
                    <a href="@Url.Action("Detail", "Trade", new { id = item.Id })" title="详细信息" target="_blank">
                        <img src="@item.Pics[0].PicUrl" width="@item.Pics[0].DisWidth" height="@item.Pics[0].DisHeight" style="margin:@item.Pics[0].DisMargin">
                    </a>
                    <span class="price" style="top:@(item.Pics[0].DisHeight + item.Pics[0].DisMarginTop - 20)px;right:0px;">￥@item.Price</span>
                    <a href="@Url.Action("Detail", "Trade", new { id = item.Id })" title="详细信息" target="_blank">
                        <p>@item.SubString(item.Description, 9)</p>
                    </a>
                 </div>
            </li>
            }
        }
        </ul>
        <div class="clear"></div>
    </div>
</div>
    @if (!CurrentUser.HasBindBabyBirthday)
    {
        CurrentUser.PopBabyBirthdayBindWind();
        @Content.Css("fancybox/jquery.fancybox-1.3.4.css", Url, BabyPlan.mvcApp.Infras.SourceRootEnums.JsLib)  
        @Content.Script("fancybox/jquery.fancybox-1.3.4.js", Url)    
        @Content.Script("fancybox.msgbox.js", Url)
        <div style="display:none"> 
        <div class="bindbabyage_box" id="bindbabyage_box" style="width:380px;height:200px;padding:20px 40px;">
            <p class="pink-font font-size20 age_line "> Hi  <span class="blue-font">&nbsp @CurrentUser.Name&nbsp</span>  您好！<br />
                <span class="font-size14">我们秉承用户既是上帝的理念，希望您填写下面的内容，只有一步哦</span>
            </p>
            <form action="@Url.Action("BindBabyAge", "User")" id="babyageform" method="post">
                <dl  class="font-size14 black-font" style="margin:10px auto;">
                    <label>您的宝宝当前：</label>
                    <input type="text" class="input_box" name="babyage" id="babyage" />&nbsp 岁
                    <span class="age_tip tip gray-font font-size12">如果您准备要宝宝，可以填写 0 岁</span>
                </dl>
                <div class="clear"></div>
                <input type="submit" value="确定" class="button-green" style="border:none;width:100px;margin:0 auto; cursor:pointer;" />
            </form>
        </div>
        <a id="babyage_link" href="#bindbabyage_box"></a>
        </div>
        <script type="text/javascript">
            $(document).ready(function () {
                var options = {
                    dataType: 'json',
                    beforeSubmit: beforeSubmit,
                    success: submitSuccess
                };
                $("#babyageform").ajaxForm(options);
                var link = $("a#babyage_link");
                link.fancybox();
                link.click();

                function beforeSubmit() {
                    var ageInput = $("#babyage");
                    var age = Number($.trim(ageInput.val()));
                    if (isNaN(age) || age < 0) {
                        ageInput.focus();
                        return false;
                    }
                    return true;
                }
                function submitSuccess(response) {
                    if (response.Error == 0) {
                        $.showMsg("保存成功！", "success");
                    }
                    else {
                        $.showMsg(response.ExMessage || response.ErrorMessage, "success", { closeTimeout: 0 });
                        setTimeout(function () { link.click(); }, 3000);
                    }
                }
            });
        </script>
    }
